package com.itheima.day04.myinnerclass.test9;

import java.util.Random;
import java.util.Scanner;

public class Test9 {
    static Random r = new Random();
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        method(new Randomset() {
            @Override
            public int getRandom(int x, int y) {
                return r.nextInt(y - x) + x;
            }
        });
        method((int x, int y) -> {
            return r.nextInt(y - x) + x;
        });
    }

    public static void method(Randomset randomset) {
        System.out.println("输入两个整数数：");
        int x = sc.nextInt();
        int y = sc.nextInt();
        int result = randomset.getRandom(x, y);
        System.out.println("产生的随机数：" + result);
    }
}

interface Randomset {
    int getRandom(int x, int y);
}

